using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Facebook.Forms
{
    public partial class FacebookAuthentication : Form
    {
        public FacebookAuthentication()
        {
            InitializeComponent();
        }

        internal FacebookAuthentication(string loginUrl)
            : this(new Uri(loginUrl))
        {
        }

        internal FacebookAuthentication(Uri loginUrl)
            : this()
        {
            wbFacebookLogin.Navigate(loginUrl);
        }

        private void wbFacebookLogin_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            if (e.Url.PathAndQuery.IndexOf("desktopapp.php") > -1)
            {
                DialogResult = DialogResult.OK;
            }
        }

        private void FacebookAuthentication_Closed(object sender, EventArgs e)
        {
            if (DialogResult != DialogResult.OK)
            {
                DialogResult = DialogResult.Cancel;
            }
        }
    }
}